<template>
  <div class="c-order-form">
    <el-form ref="form" :model="form" label-width="120px">
      <el-form-item label="订单所属计划">
        <el-input v-model="form.inPlan" placeholder="请选择订单所属计划" disabled />
      </el-form-item>
      <el-form-item label="订单名称">
        <el-input v-model="form.name" disabled />
      </el-form-item>
      <el-form-item label="订单描述" prop="description">
        <el-input v-model="form.description" placeholder="请输入订单描述" disabled />
      </el-form-item>
      <el-form-item label="一些参数" prop="argPlaceholder" >
        <el-input v-model="form.argPlaceholder" placeholder="请输入一些参数" disabled />
      </el-form-item>
      <el-form-item label="审批结果">
        <el-radio-group v-model="form.result">
          <el-radio label="true">同意</el-radio>
          <el-radio label="false">拒绝</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="审批意见">
        <el-input type="textarea" v-model="form.comment"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">提交</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>

const keyMap = {
  assignee: "allow",
};

export default {
  props: {
    step: {
      type: String,
      default: ""
    },
    formInfo: {
      type: Object,
      default: () => ({})
    }
  },
  data() {
    return {
      form: {
        inPlan: "",
        name: "",
        description: "",
        argPlaceholder: "",
      }
    };
  },
  watch: {
    formInfo(newFormValue) {
      this.form.inPlan = newFormValue.inPlan;
      this.form.name = newFormValue.name;
      this.form.description = newFormValue.description;
      this.form.argPlaceholder = newFormValue.argPlaceholder;
    }
  },
  methods: {
    onSubmit() {
      const params = {
        ...this.form
      };
      params[keyMap[this.step]] = this.form.result;
      this.$emit("submit", params)
    }
  }
};
</script>
